package com.winchain.provider;

import com.shell.bee.base.annotation.Logging;
import com.shell.bee.base.utils.JsonUtil;
import com.shell.bee.mvc.controller.BaseController;
import com.shell.customer.po.CusExtra;
import com.winchain.chainbill.asset.biz.credit.service.CreditAssetMgtService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CustomerNotifyProvider extends BaseController {
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private CreditAssetMgtService creditAssetMgtService;

	@RequestMapping({ "/afterCusAccredit" })
	@Logging(methods = "������������")
	@ResponseBody
	public void afterCusAccredit(String cus, String cusExtra, String finId) throws Exception {
		this.logger.info("=============== ��������������������������������  start ====================");
		this.logger.info("finId: " + finId);
		this.logger.info("cus: " + cus);
		this.logger.info("cusExtra: " + cusExtra);
		CusExtra cusExtraObj = (CusExtra) JsonUtil.fromJson(cusExtra, CusExtra.class);
		if (cusExtraObj.getCreditLine() != null) {
			this.logger.info("������������");
			this.creditAssetMgtService.distribute("1", cusExtraObj.getCreditLine(), finId, cusExtraObj.getCusId(),
					new String[0]);
		}
		this.logger.info("=============== ��������������������������������  end====================");
	}
}
